package com.example.boot.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.Result;
import com.example.pojo.entity.Entrust;
import com.example.pojo.entity.Project;
import com.example.pojo.vo.TreeData;
import com.example.service.EntrustService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * TODO
 *
 * @author ding
 * @since 2024/6/6
 */
@RestController
@RequestMapping("/entrust")
@Api(tags = "颁布单位相关接口")
public class EntrustController {

    @Autowired
    private EntrustService entrustService;

    @ApiOperation("根据id获取发布单位信息")

//    @PreAuthorize("hasAuthority('ENTRUST_QUERY')")
    @GetMapping("/selectById/{id}")
    public Result selectById(@PathVariable Integer id){
        Entrust entrust = entrustService.getById(id);
        return Result.success(entrust);
    }

    @ApiOperation("分页获取发布单位信息")
//    @PreAuthorize("hasAuthority('ENTRUST_PAGEQUERY')")
    @GetMapping("/selectPage")
    public Result selectPage(String name,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10") Integer pageSize) {
        Page<Entrust> page = entrustService.selectPage(name, pageNum, pageSize);
        return Result.success(page);
    }

//    @PreAuthorize("hasAuthority('ENTRUST_QUERY')")
    @GetMapping("/selectProject/{id}")
    public Result selectProjectByEntrustId(@PathVariable Integer id) {
        List<Project> projectList = entrustService.selectProjectByEntrustId(id);
        return Result.success();
    }

    @ApiOperation("新增发布单位信息")
//    @PreAuthorize("hasAuthority('ENTRUST_ADD')")
    @PostMapping("/add")
    public Result addEntrust() {

        return Result.success();
    }

    @ApiOperation("删除发布单位信息")
//    @PreAuthorize("hasAuthority('ENTRUST_DELETE')")
    @DeleteMapping("/delete")
    public Result deleteEntrust() {

        return Result.success();
    }

}
